<template>
  <div class="container">
    <el-button type="primary" class="send" @click="dialogFormVisible = true">新建产品</el-button>
    <el-table :data="tableData" border>
      <el-table-column prop="date" label="名称" />
      <el-table-column prop="name" label="简介" />
      <el-table-column prop="address" label="时间" />
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            size="mini"
            @click="handleEdit(scope.$index, scope.row)"
          >编辑</el-button>
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog title="发消息" :visible.sync="dialogFormVisible">
      <el-form :model="form" class="left">
        <el-form-item label="消息内容" :label-width="formLabelWidth">
          <el-input v-model="form.textarea" type="textarea" :rows="2" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="类型" :label-width="formLabelWidth" class="left">
          <el-select v-model="form.region" placeholder="请选择活动区域">
            <el-option label="区域一" value="shanghai" />
            <el-option label="区域二" value="beijing" />
          </el-select>
        </el-form-item>
        <el-form-item label="接收人" :label-width="formLabelWidth">
          <el-select v-model="form.region" placeholder="请选择活动区域">
            <el-option label="区域一" value="shanghai" />
            <el-option label="区域二" value="beijing" />
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer btn">
        <el-button type="primary" @click="dialogFormVisible = false">发 送</el-button>
        <el-button @click="dialogFormVisible = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
export default {
  data() {
    return {
      tableData: [
        {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        },
        {
          date: '2016-05-04',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1517 弄'
        },
        {
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1519 弄'
        },
        {
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1516 弄'
        }
      ],
      dialogFormVisible: false,
      formLabelWidth: '120px',
      form: {
        textarea: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: ''
      }
    }
  },
  methods: {
    handleEdit(index, row) {
      console.log(index, row)
    },
    handleDelete(index, row) {
      console.log(index, row)
    }
  }
}
</script>
<style lang="scss" scoped>
.container {
  padding: 10px 10px 0 10px;
}
.send {
  margin-bottom: 20px;
}
.btn{
    display: flex;
    justify-content: space-around;
}
</style>
